<?php
/**
 * 兼容第三方插件补丁文件
 * @来自第三方接口文件
 */
	defined('BY_JYA') or exit('error');
	list($tplid,$url)=$arguments;
	$path = ROOT_AT . '/images/';
	$file =random('10').'.png';
	$tpl=pdo_get('jy_move_template',array('id'=>$tplid));
	$position=json_decode($tpl['position'],true);
	$w=substr($position['width'],0,strlen($position['width'])-2);
	$h=substr($position['width'],0,strlen($position['height'])-2);
	$bg=tomedia($tpl['image']);
	$bg=$this->resize_image($bg,'320','320');
	//$bg=imagecreatefrompng($bg);
	//$bg=imagecreatefromstring(file_get_contents($bg));
	$qr=cfc('tools')->createqrcode($url,$w);
	$qr=imagecreatefromstring($qr);
	$target = imagecreatetruecolor(320, 320);
	imagecopy($target, $bg, 0, 0, 0, 0, 320, 320);
	
	imagecopyresized($target, $qr, $position['left'], $position['top'], 0, 0, $position['width'], $position['height'], $w, $h);
	imagepng($target, $path . $file);
	$url=cfc('files')->source_save($path . $file,'image','png');
	imagedestroy($target);
	unlink($path . $file);
	return $url;
	
